package com.nengchuan.eic.nceconomy.controller;

import com.nengchuan.eic.nceconomy.entity.po.IndexDict;
import com.nengchuan.eic.nceconomy.entity.vo.IndexListVO;
import com.nengchuan.eic.nceconomy.service.IndexDictService;
import com.nengchuan.eic.nceconomy.service.OssService;
import com.nengchuan.model.model.WrappedResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 功能描述:
 *
 * @Author: liurui
 * @Date: 2020/4/26 0026 上午 11:44
 */
@RestController
@RequestMapping("/api/dict")
@Api(value = "DictController", tags = "字典信息")
public class DictController {

    @Autowired
    private IndexDictService indexDictService;

//    @Autowired
//    private OssService ossService;
//    @ApiOperation("oss")
//    @PostMapping(value = "/ossService", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiResponse(code = 200, message = "成功为true,失败为false", response = WrappedResult.class)
//    public WrappedResult ossService(MultipartFile file) throws Exception {
//        return WrappedResult.success(ossService.uploadByOss(file));
//    }
    @ApiOperation("查询项目流程分类字段属性")
    @GetMapping(value = "/project_category/{type}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiResponse(code = 200, message = "成功为true,失败为false", response = WrappedResult.class)
    public WrappedResult<List<IndexDict>> getProjectCategory(@PathVariable("type") String type) {
        return WrappedResult.success(indexDictService.getDetailList(type));
    }


    @ApiOperation("查询指标")
    @GetMapping(value = "/index", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiResponse(code = 200, message = "成功为true,失败为false", response = WrappedResult.class)
    public WrappedResult<IndexListVO> getIndex(@RequestParam("name") String name) {
        return WrappedResult.success(indexDictService.getIndex(name));
    }
}
